<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">

<div class="panel">
    <div id="classes-heading" class="panel-heading bg-gray-light">
        <h3 class="panel-title">指标卡片<span id="title-duty-name-target" class="text-muted"> | </span></h3>

        <ul class="nav nav-tabs" data-ul="target_nav_ul">
            <li class="active"><a th:href="'#to_target_tab1'+${target?.id}" th:id="'target_tab1'+${target?.id}" data-toggle="tab">指标简要</a></li>
            <li class=""><a th:href="'#to_target_tab2'+${target?.id}" th:id="'target_tab2'+${target?.id}" data-toggle="tab">指标描述</a></li>
            <li class=""><a th:href="'#to_target_tab3'+${target?.id}" th:id="'target_tab3'+${target?.id}" data-toggle="tab">指标评测</a></li>
        </ul>

    </div>

    <div class="panel-body">
        <div class="tab-content">
            <div class="tab-pane fade in active" th:id="'to_target_tab1'+${target?.id}">
                <form th:id="'form_target_input'+${target?.id}" class="form-horizontal" autocomplete="off">
                    <input type="hidden" name="keyId" th:value="${target?.id}">
                    <input type="hidden" name="flowDutyId">
                    <input type="hidden" name="flowDutyName">

                    <div class="form-group">
                        <label class="col-md-2 control-label">指标编号</label>
                        <div class="col-md-8">
                            <input disabled type="text" id="targetNo" th:value="${target?.targetNo}" class="form-control" placeholder="指标编号">
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="col-md-2 control-label">指标名称<i class="fa fa-asterisk txt-color-red"></i></label>
                        <div class="col-md-8">
                            <input disabled type="text" name="name" id="name" th:value="${target?.name}" class="form-control" placeholder="指标名称">
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="col-md-2 control-label">指标分类<i class="fa fa-asterisk txt-color-red"></i></label>
                        <div class="col-md-8">
                            <select disabled id="targetClassDictId" name="targetClassDictId" class="form-control">
                                <option value="">请选择</option>
                                <option th:each="dict : ${targetClassDictList}" th:id="${dict.id}" th:value="${dict.id}" th:text="${dict.name}" th:selected="${dict == target?.targetClassDict}"></option>
                            </select>
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="col-md-2 control-label">指标重要等级<i class="fa fa-asterisk txt-color-red"></i></label>
                        <div class="col-md-8">
                            <div class="radio">
                                <input disabled type="radio" name="level" id="level1" value="1" class="magic-radio" th:checked="${target?.level == 1}" >
                                <label for="level1">一级</label>
                                <input disabled type="radio" name="level" id="level2" value="2" class="magic-radio" th:checked="${target?.level == 2}" >
                                <label for="level2">二级</label>
                                <input disabled type="radio" name="level" id="level3" value="3" class="magic-radio" th:checked="${target?.level == 3}" >
                                <label for="level3">三级</label>
                            </div>
                        </div>
                    </div>

                    <div class="form-group" id="parentTargetDiv">
                        <label class="col-md-2 control-label">上级指标</label>
                        <div class="col-md-8">
                            <input disabled type="text" id="parentTargetName" th:value="${parentTargetName}" class="form-control" placeholder="选择上级指标">
                            <input type="hidden" name="parentTargetId" id="parentTargetId" th:value="${target?.parentTargetId}" class="form-control">
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="col-md-2 control-label">指标标签</label>
                        <div class="col-md-8">
                            <input disabled type="text" name="targetLabel" id="targetLabel" th:value="${target?.targetLabel}" class="form-control" placeholder="指标标签">
                        </div>
                    </div>

                    <div class="form-group" id="relatedTargetDiv">
                        <label class="col-md-2 control-label">关联指标</label>
                        <div class="col-md-8">
                            <input disabled type="text" name="relatedTargetNames" id="relatedTargetNames" th:value="${target?.relatedTargetNames}" class="form-control" placeholder="">
                            <input type="hidden" name="relatedTargetIds" id="relatedTargetIds" th:value="${target?.relatedTargetIds}" class="form-control">
                        </div>
                    </div>

                </form>
            </div>

            <div class="tab-pane fade in" th:id="'to_target_tab2'+${target?.id}">2</div>
            <div class="tab-pane fade in" th:id="'to_target_tab3'+${target?.id}">3</div>
        </div>

    </div>
</div>

<script th:inline="javascript">
    var keyId_target = [[${target?.id}]];
    var flowData_target = {
        keyId : keyId_target ? keyId_target : "create",
        formId : "form_target_input"+[[${target?.id}]],
        path : "com.hanqian.kepler.core.entity.primary.core.Target",
        titleId : "title-duty-name-target"
    };
    var $form = $("#"+flowData_target.formId);

    $(function(){
        $form.find("input,select").attr("disabled", true);

        __flow_duty_handle(flowData_target);
        __flow_button_read_handle(flowData_target, fn_target_approve, fn_target_back, fn_target_deny, fn_target_edit, fn_target_withdraw);

        __select2(flowData_target.formId + " #targetClassDictId");

        //关联指标 标签栏
        $("#relatedTargetNames").amsifySuggestags();
        $("#relatedTargetDiv .amsify-suggestags-input").attr("disabled", true);
        $("#relatedTargetDiv .amsify-suggestags-input").css("background-color", "#FFF");
        // $("#relatedTargetDiv .amsify-suggestags-input-area").css("background-color", "#eee");
        $("#relatedTargetDiv").find(".amsify-remove-tag").remove();
    });

    function fn_target_approve(){
        __confirm_dialog("", "确定通过审批吗？", function(dialogRef){
            __form_save(flowData_target.formId, ctx+"target/approve", function(data){
                if(data && data.state === 1){
                    dialogRef.close();
                    __flow_close_layx(flowData_target);
                }
            })
        });
    }

    function fn_target_back(){
        __confirm_dialog("", "确定退回吗？", function(dialogRef){
            __form_save(flowData_target.formId, ctx+"target/back", function(data){
                if(data && data.state === 1){
                    dialogRef.close();
                    __flow_close_layx(flowData_target);
                }
            })
        });
    }

    function fn_target_deny(){
        __confirm_dialog("", "确定否决吗？", function(dialogRef){
            __form_save(flowData_target.formId, ctx+"target/deny", function(data){
                if(data && data.state === 1){
                    dialogRef.close();
                    __flow_close_layx(flowData_target);
                }
            })
        });
    }

    function fn_target_edit(){
        __flow_close_layx(flowData_target);
        __layX_html_read(flowData_target.keyId, "指标卡片", ctx+"target/input?keyId="+flowData_target.keyId);
    }

    function fn_target_withdraw(){
        __confirm_dialog("", "确定撤回吗？", function(dialogRef){
            __form_save(flowData_target.formId, ctx+"target/withdraw", function(data){
                if(data && data.state === 1){
                    dialogRef.close();
                    __flow_close_layx(flowData_target);
                }
            })
        });
    }

    //切换标签页要清理流程按钮组
    $("ul[data-ul='target_nav_ul']").on("click", "li", function(){
        __flow_button_clean_handle(flowData_target);
    });

    //点击自身 需要重新获取流程按钮组
    $("#target_tab1"+keyId_target).on("click", function(){
        __flow_button_read_handle(flowData_target, fn_target_approve, fn_target_back, fn_target_deny, fn_target_edit);
    });

    //进入指标描述
    $("#target_tab2"+keyId_target).on("click", function(){
        loadURL(ctx + "main/menu/core/targetDesc?parentId="+keyId_target, $("#to_target_tab2"+keyId_target));
    });

    //进入指标评测
    $("#target_tab3"+keyId_target).on("click", function(){
        loadURL(ctx + "main/menu/core/targetEvaluate?parentId="+keyId_target, $("#to_target_tab3"+keyId_target));
    });

</script>

</html>